<template>
  <div class="bg">
    <nav-com
      :title="$t('yuyan')"
      :showView='showView'
      @back="backHandler()"
    ></nav-com>
    <div class="top-view1">
      <van-radio-group v-model="unit">
        <van-cell-group inset class="m-b-10 m-t-10">
          <van-cell :title="$t('language.zh')" clickable @click="unit = 'zh';subchange()">
            <template #right-icon>
              <van-radio name="zh"  checked-color="#00DEA1"/>
            </template>
          </van-cell>
        </van-cell-group>
        <van-cell-group inset class="m-b-10">
          <van-cell :title="$t('language.en')" clickable @click="unit = 'en';subchange()">
            <template #right-icon>
              <van-radio name="en" checked-color="#00DEA1"/>
            </template>
          </van-cell>
        </van-cell-group>
        <van-cell-group inset class="m-b-10">
          <van-cell :title="$t('language.es')" clickable @click="unit = 'es';subchange()">
            <template #right-icon>
              <van-radio name="es" checked-color="#00DEA1"/>
            </template>
          </van-cell>
        </van-cell-group>
      </van-radio-group>
    </div>
  </div>
</template>
<script>
import { Toast } from 'vant'
import navCom from '@/components/nav-com.vue'
import { profile } from '../../api/user'
export default {
  name: 'bonusList',
  components: {
    navCom
  },
  data () {
    return {
      unit: '',
      showView: true,
      title: '语言切换',
      showPage: true,
      lichengValue: ''
    }
  },
  mounted () {
    this.unit = localStorage.getItem('lang') || 'zh'
    this.init()
  },
  methods: {
    jumpTo (url) {
      this.$router.push(url)
    },
    subchange () {
      this.$i18n.locale = this.unit
      localStorage.setItem('lang', this.$i18n.locale)
      const nav = navigator.userAgent
      if (nav.indexOf('Android') > -1 || nav.indexOf('Adr') > -1) {
        phone.getLangues(this.$i18n.locale)
      } else if (nav.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)) {
        this.$bridge.callhandler('getLangues', { id: this.$i18n.locale }, res => {})
      }
      setTimeout(() => {
        this.backHandler()
      }, 500)
    },
    // 返回
    backHandler () {
      this.$router.go(-1)
    },
    // 初始化
    init () {
    }
  }
}
</script>
<style lang="scss" scoped>
.top-view1{
  margin-top: 26.23vw;
}
.m-b-10{
  margin-bottom: 10px;
}
.m-t-10{
  margin-top: 10px;
}
.van-cell__title, .van-cell__value {
  flex: 1;
  display: flex;
  align-items: center;
}
::v-deep .van-cell{
  font-size: 20px!important;
}
</style>
